<?php echo "Hello There."; ?><br />
<?php
//require_once('Zend/Loader.php');
//Zend_Loader::registerAutoload();

require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

// load the application configuration
$config = new Zend_Config_Ini('../settings.ini', 'development');
Zend_Registry::set('config', $config);

// create the application logger
$logger = new Zend_Log(new Zend_Log_Writer_Stream($config->logging->file));
Zend_Registry::set('logger', $logger);
//$logger->debug("My Test");


// connect to the database
$params_array = array('host' => $config->database->hostname,
    'username' => $config->database->username,
    'password' => $config->database->password,
    'dbname' => $config->database->database);
$db = Zend_Db::factory($config->database->type, $params_array);
Zend_Registry::set('db', $db);
$db->query("Select 1");

// setup application authentication
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session());

// handle the user request
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory($config->paths->base . '/include/Controllers');
$controller->registerPlugin(new CustomControllerAclManager($auth));
$controller->throwExceptions(true);

// setup the view renderer
$vr = new Zend_Controller_Action_Helper_ViewRenderer();
$vr->setView(new Templater());
$vr->setViewSuffix('tpl');
Zend_Controller_Action_HelperBroker::addHelper($vr);
echo " --> Before Dispatch <br />";
$controller->dispatch();
echo "After Dispatch <--  <br />";
?>

<?php
// assume that $config is already defined
require_once('Smarty/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = $config->paths->templates;
$smarty->compile_dir = $config->paths->data . '/tmp/templates_c';
echo ">>> Before Smarty <br />";
$smarty->display('foo.tpl');
echo "After Smarty <<< <br />";
?>

